package com.wty.love.database.dao;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import com.wty.love.database.entity.Diary;

import java.util.List;

@Dao
public interface DiaryDao {

    /**
     * insert diary
     * @param diary
     */
    @Insert
    void insertDiary(Diary diary);

    /**
     * update diary by diary's id
     * @param diary you want update entity
     * @return The affected row
     */
    @Update
    int updateDiary(Diary diary);

    /**
     * (normal)query diary from small to big
     * @return diary list
     */
    @Query("select * from Diary where state == 0 ORDER BY ID DESC")
    List<Diary> getAllDiaryDesc0();

    /**
     * (normal)query diary from big to small
     * @return diary list
     */
    @Query("select * from Diary where state == 0 ORDER BY ID ASC")
    List<Diary> getAllDiaryAsc0();

    @Delete
    void deleteDiaryByPosition(Diary diary);
}
